亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

ChucK初步(9)

2019-11-11 04:58:28
字體:
來源:轉載
供稿:網友

concurrency, PRocesses, shreds

sporking shredsthe 'me' keyWordusing machine.add()inter-shred communication

Concurrency & Shreds

…is able to run many processes concurrently…

A ChucKian process is called a shred. To spork a shred means creating and adding a new process to the virtual(虛擬的) machine. Shreds may be sporked from a variety of places(各種各樣的地方), and may themselves spork new shreds.

(直接代換理解:spork a shred == creating & adding a process)

ChucK supports sample-synchronous(采樣同步), non-preemptive concurrency(非搶占式并發). Via the timing mechanism(機制). any number of programs/shreds can be automatically(自動的) shreduled(往后看,便于理解,實際上就是創建添加的過程,感覺就像是shred動作化了) and synchronized(同步的) use the timing information.A shreduler in the virtual(虛擬的) machine does the shreduling. The concurrency(并發性) is ‘sample-synchronous’, meaning that inter-process audio timing is guaranteed(保證) to be precise(精確的) to the sample(樣品). Note that each process/shred does not necessarily need to know about each other - it only has to deal with time locally. The virtual machine will make sure things happen correctly “across the board(全體,全面)”. Finally, concurrency - like timing - is deterministic(確定性的) in ChucK.

The simplest way to to run shreds concurrently is to specify(指定) them on the command line:

chuck foo.ck bar.ck boo.ck

The above command runs chuck on foo.ck, bar.ck, and boo.ck concurrently. There are other ways to run shreds concurrently (see on-the-fly programming commands). Next, we show how to create new shreds from within ChucK programs.

sporking shreds (in code)

To spork means to shredule a new shred.

To spork a shred, use the spork keyword/Operator:

spork dynamically(動態地) sporks shred from a function call從函數調用中動態創建進程this operation is sample-synchronous, the new shred is shreduled to execute(執行) immediately新進程創建來立即執行the parent shred continues to execute, until time is advanced (see manipulating time) or until the parent explicitly(顯式地) yields(產生) (see next section).父進程繼續執行,直到時間被推進或者直到父進程顯示產生。in the current implementation(實現), when a parent shred exits, all child shreds all exit (this behavior(行為) will be enhanced(提高) in the future.)在當前實現中,當父進程退出,所有的子進程會退出。sporking a functions returns reference to the new shred, note that this operation does not return what functions returns - the ability to get back the return value at some later point in time will be provided in a future release.產生一個函數返回新進程的引用,注意這個操作不會返回函數返回值-返回在某個靠后的時間點上的返回值的能力就被在未來的版本中提供。// define function go()fun void go(){ // insert code}// spork a new shred to start running from go()spork ~ go();// spork another, store reference to new shred in offspringspork ~ go() => Shred @ offspring;

a slightly longer example:

// define functionfun void foo( string s ){ // infinite time loop while( true ) { // print s <<< s >>>; // advance time 5::second => now; }}// spork shred, passing in "you" as argument to foospork ~ foo( "you" );// advance time by 2s2::second => now;// spork another shredspork ~ foo( "me" );// infinite time loop - to keep child shreds aroundwhile( true ) 1::second => now;//測量://輸出you后,第2s輸出me,第5s再次輸出

兩個進程互有交錯,”you”先輸出,”me”后輸出,循環輸出。 個人理解:1::second => now;感覺上就像是將進程掛起,sleep()的感覺就像是1s后再跳到這個程序。

Created with Rapha?l 2.1.0youyoumeme2s3s

the ‘me’ keyword

The me keyword (type Shred) refers the current shred.

Sometimes it is useful to suspend(暫停) the current shred without advancing time, and let other shreds shreduled for the current time to execute(實行). me.yield() does exactly that. This is often useful immediately after sporking a new shred, and you would like for that shred to have a chance to run but you do not want to advance time yet for yourself.

// spork shredspork ~ go();// suspend the current shred ...// ... give other shreds (shreduled for 'now') a chance to runme.yield();

It may also be useful to exit the current shred. For example if a MIDI device(裝置) fails to open, you may exit the current shred.

// make a MidiIn objectMidiIn min;// try to open device 0 (chuck --probe to list all device)if( !min.open( 0 ) ){ // print error message <<< "can't open MIDI device" >>>; // exit the current shred me.exit();}

You can get the shred id:

// print out the shred id<<< me.id(); >>>;

These functions are common to all shreds, but yield() and exit() are commonly used with the current shred.

using machine.add()

Machine.add( string path ) takes the path to a chuck program, and sporks it. Unlike spork ~, there is no parent-child relationship between the shred that calls the function and the new shred that is added. This is useful for dynamically(動態地) running stored programs.

// spork "foo.ck"Machine.add( "foo.ck" );

Presently, this returns the id of the new shred, not a reference to the shred. This will likely be changed in the future.

Similarly, you can remove shreds from the virtual(虛擬的) machine.

// addMachine.add( "foo.ck" ) => int id;// remove shred with idMachine.remove( id );// addMachine.add( "boo.ck" ) => id// replace shred with "bar.ck"Machine.replace( id, "bar.ck" );

inter-shred communication

Shreds sporked in the same file can share the same global variables(變量). They can use time and events to synchronize to each other. (see events) *Shreds sporked from different files can *share data (including events).**For now, this is done through a public class with static data (see classes). Static data is not completely implemented! We will fix this very soon!

command line arguments

ChucK supports passing arbitrary(任意的) data from the command line into ChucK programs using optional(可選擇的) command line arguments. An argument is specified(指定) by appending(附加) a colon(冒號) character “:” to the name of the ChucK program to which you wish to send that argument, followed by the argument itself.

chuck foo.ck:foo

Multiple arguments can be specified, each separated by the colon character.

chuck foo.ck:foo:bar:boo

Furthermore(此外), each ChucK program has its own set of arguments, which are specified separately.

chuck foo.ck:foo bar.ck:bar boo.ck

Command line arguments can also be used when using on-the-fly programming facilities(即時編程工具) of ChucK.

chuck + foo.ck:foo bar.ck:bar:boo

(后面有一篇博文會講解相關參數功能的,包括這里的+)

Machine.add() and Machine.replace() accept command line arguments in a similar fashion.

// add foo.ck// pass foo and bar as command line argumentsMachine.add( "foo.ck:foo:bar" ) => int id;// replace shred with "bar.ck"http:// pass foo and bar as command line argumentsMachine.replace( id, "bar.ck:foo:bar" );

To access command line arguments within a ChucK program, use the me.args() and me.arg() functions.

// print out all argumentsfor( int i; i < me.numArgs(); i++ ) <<< me.arg( i ) >>>;

直接運行會輸出: C:/Users/abc1/Desktop>chuck test.ck:foo [test.ck]:line(2): class ‘Shred’ has no member ‘numArgs’

(真就尷尬了)


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
91人人爽人人爽人人精88v| 亚洲精品电影网| 欧美疯狂做受xxxx高潮| 欧美视频在线观看 亚洲欧| 欧日韩不卡在线视频| 欧美体内谢she精2性欧美| 欧美—级高清免费播放| 最新69国产成人精品视频免费| 亚洲精品视频免费| 国产精品99久久久久久www| 欧美大全免费观看电视剧大泉洋| 亚洲视频一区二区| 国模私拍视频一区| 91久久精品国产91久久性色| 亲子乱一区二区三区电影| 2019中文字幕在线| 国产精品福利在线观看| 69国产精品成人在线播放| 日韩视频一区在线| 啊v视频在线一区二区三区| 久久精视频免费在线久久完整在线看| 日韩av中文字幕在线免费观看| 午夜欧美大片免费观看| 国产不卡在线观看| 久久久人成影片一区二区三区观看| 91国内揄拍国内精品对白| 国产视频亚洲精品| 亚洲男人第一av网站| 日韩av快播网址| 国产精品久久久久久婷婷天堂| 国产精品福利在线| 亚洲国产成人精品久久久国产成人一区| 亚洲第一视频在线观看| 久久久久国产视频| 清纯唯美日韩制服另类| 91亚洲精品久久久久久久久久久久| 97香蕉超级碰碰久久免费的优势| 久久久免费精品视频| 亚洲欧洲一区二区三区久久| 国产精品久久中文| 91国产视频在线播放| 国内外成人免费激情在线视频网站| 日韩电视剧免费观看网站| 久久噜噜噜精品国产亚洲综合| 一区二区日韩精品| 亚洲精品资源美女情侣酒店| 日韩av最新在线| 日韩欧美高清在线视频| 欧美激情综合色| 日韩在线中文视频| 91久久精品国产91久久性色| 深夜福利91大全| 亚洲国产天堂久久综合| 日韩成人激情在线| 欧美极品少妇xxxxⅹ裸体艺术| 国产精品视频内| 国产一区二区三区视频在线观看| 欧日韩不卡在线视频| 91精品久久久久久久久久另类| 日韩一区二区三区在线播放| 久久久久久久久久亚洲| 亚洲欧美中文字幕在线一区| 人九九综合九九宗合| 欧美视频国产精品| 国产精品人成电影| 亚洲欧美日韩国产中文专区| 国产精品观看在线亚洲人成网| 97在线视频免费播放| 日本高清不卡的在线| 97在线视频免费| 国产精品激情自拍| 日本一区二区在线播放| 97在线视频免费播放| 成人精品一区二区三区电影免费| 久久久久久中文| 国产精品偷伦一区二区| 亚洲专区中文字幕| 韩国三级日本三级少妇99| 日韩欧美aⅴ综合网站发布| 国产精品亚洲美女av网站| 欧美性猛交xxxxx免费看| 亚洲黄页视频免费观看| 欧美日韩黄色大片| 91黑丝高跟在线| 亚洲精品白浆高清久久久久久| 欧美成人亚洲成人| 97视频免费看| 国产精品丝袜久久久久久不卡| 91精品国产综合久久香蕉922| 国模精品视频一区二区三区| 亚洲国产成人精品女人久久久| 亚洲欧洲一区二区三区在线观看| 国产一区欧美二区三区| 国产精品wwwwww| 国产精品欧美在线| 亚洲www视频| 日本精品视频在线| 91欧美精品午夜性色福利在线| 国产精品日韩久久久久| www.日韩视频| 成人在线视频福利| 北条麻妃久久精品| 欧美巨猛xxxx猛交黑人97人| 亚洲一区二区免费| 97视频人免费观看| 欧美精品中文字幕一区| 国产精品视频99| 亚洲一区999| 欧美日韩免费在线观看| 人人做人人澡人人爽欧美| 国产精品99久久久久久人| 日韩精品视频中文在线观看| 亚洲香蕉成人av网站在线观看| 中文字幕在线看视频国产欧美在线看完整| 国产乱人伦真实精品视频| 成人免费在线视频网站| 国产精品美女无圣光视频| 欧美日韩精品在线| www.日韩视频| 欧美性受xxx| 日韩成人中文字幕在线观看| 欧美另类精品xxxx孕妇| 一区二区三区 在线观看视| 国产欧美日韩中文字幕| 成人妇女淫片aaaa视频| 日韩成人激情影院| 亚洲性av网站| 国产欧美最新羞羞视频在线观看| 亚洲综合日韩中文字幕v在线| 久久福利网址导航| 国产日韩欧美综合| 欧美激情a∨在线视频播放| 日韩av有码在线| 57pao成人永久免费视频| 日韩中文有码在线视频| 欧美性猛交xxxx| 国产精彩精品视频| 亚洲午夜精品视频| 国产精品草莓在线免费观看| 91高清视频在线免费观看| 亚洲免费一在线| 亚洲美腿欧美激情另类| 亚洲男人7777| 国产精品欧美日韩一区二区| 亚洲一区二区国产| 精品亚洲一区二区三区四区五区| 久久免费精品视频| 欧美大片欧美激情性色a∨久久| 欧美黄色片在线观看| 日本精品在线视频| 国产精品丝袜白浆摸在线| 日韩视频免费观看| 亚洲国产精品女人久久久| 国产精品香蕉在线观看| 北条麻妃久久精品| 国内精品久久久久久影视8| 亚洲精品国产品国语在线| 亚洲成人激情在线| 97视频在线观看免费高清完整版在线观看| 日韩av观看网址| 欧美一区二区大胆人体摄影专业网站| 色偷偷91综合久久噜噜| 九九久久综合网站| 欧美肥婆姓交大片|